#include "QQuickROData.h"
#include "ROSyncObject.h"

ROSyncObject::ROSyncObject(QObject *parent):QObject(parent)
{

}

ROSyncObject::Role ROSyncObject::role() const
{
    return m_role;
}

void ROSyncObject::setRole(const Role &newRole)
{
    if (m_role == newRole)
        return;
    m_role = newRole;
    emit roleChanged();
}

void ROSyncObject::initialize()
{
    auto data = getROObjectData(this);
    if(data)
    {
        if(data->host)
        {
            setRole(Host);
        }
        else if(data->node)
        {
            setRole(Client);
        }
    }
    else{
        setRole(Individual);
    }
}

